<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Model;
use Think\Model;
/**
 * Description of IntegralModel
 *
 * @author Administrator
 */
class IntegralModel extends Model {
    //put your code here
    
    protected  $tableName = 'integral';
    
	public function getList($where=[],$needPage=true){
		
		if($needPage){
			$count = $this->where($where)->count();
		
			$p = getPage($count,15);
			$list = $this->where($where)->order('ctime desc')->limit($p->firstRow, $p->listRows)->select();
			
			return array('list'=>$this->checkList($list),'page'=>$p->show());
			
		}else{
			$list = $this->where($where)->order('ctime desc')->select();
			return array('list'=>$this->checkList($list));
		}
		
		
	}
	
	
	private function checkList($data){
		
		foreach($data as $k=>$v){
			$data[$k]['ctime_str'] = Date("m-d",$v['ctime']);
			$data[$k]['status_str'] = $v['status'] == 1 ? '转入' : '转出';
			$data[$k]['type_str'] = $v['type'] == 1 ? '积分账户' : '待返还账户';
		}
		
		return $data;
	}
}
